package com.boatAnchorAssistant.service.controller.app;

import com.boatAnchorAssistant.pojo.param.userCollect.*;
import com.boatAnchorAssistant.pojo.vo.userCollect.*;
import com.boatAnchorAssistant.service.service.in.*;
import nirvana.core.domains.vo.PageResult;
import nirvana.core.domains.vo.ApiResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

import java.util.List;

/**
 * app/我的收藏
 * 【描 述】：
 * 【环 境】：J2SE
 * 【详 细】：
 */
@RestController
@RequestMapping("/userCollect/app")
public class UserCollectAppController {

    private final UserCollectService service;

    public UserCollectAppController(UserCollectService service) {
        this.service = service;
    }


    /**
     * 创建我的收藏
     *
     * @param param
     * @return
     */
    @PostMapping("/createUserCollect")
    public ApiResult createUserCollect(@RequestBody @Valid CreateUserCollectParam param) {
        service.createUserCollect(param);
        return ApiResult.ok();
    }


    /**
     * 切换收藏状态
     * @param deviceId
     * @return
     */
    @GetMapping("/switchUserCollect")
    public ApiResult switchUserCollect(@RequestParam("deviceId") Long deviceId) {
        service.switchUserCollect(deviceId);
        return ApiResult.ok();
    }

    /**
     * 获取我的收藏列表
     *
     * @param param
     * @return
     */
    @PostMapping("/getUserCollectList")
    public ApiResult<PageResult<GetUserCollectListVo>> getUserCollectList(@RequestBody GetUserCollectListParam param) {
        PageResult<GetUserCollectListVo> result = service.getUserCollectList(param);
        return ApiResult.ok(result);
    }


    /**
     * 获取我的收藏下拉列表
     *
     * @return
     */
    @PostMapping("/getUserCollectDownList")
    public ApiResult<List<GetUserCollectDownListVo>> getUserCollectDownList(@RequestBody(required = false) @Valid GetUserCollectDownListParam param) {
        List<GetUserCollectDownListVo> list = service.getUserCollectDownList(param);
        return ApiResult.ok(list);
    }


}

